import time
import threading
"""
创建线程对象:
    threading.Thread(group=None, target=执行的目标任务名, args=(以元组的方式给执行任务传参), 
    kwargs=(以字典的方式给执行任务传参),name=(线程名，一般不用设置))
"""


def sing(msg):
    while True:
        print(msg)
        time.sleep(1)


def dance(msg):
    while True:
        print(msg)
        time.sleep(1)


if __name__ == '__main__':
    # sing("我在唱歌...") 如果只使用一个主线程运行，那么dance永远得不到执行
    # dance("我在跳舞...")

    # 开启多线程
    sing_thread = threading.Thread(target=sing, args=("唱歌...",))
    dance_thread = threading.Thread(target=dance, kwargs={"msg": "...跳舞"})
    sing_thread.start()
    dance_thread.start()
